package com.qf.provider.controller;

import com.qf.common.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/getall")
    public List<User> getAll(){

        User user01 = new User(1, "luffy", 19);
        User user02 = new User(2, "zero", 22);

        return Arrays.asList(user01, user02);

    }

    @PostMapping("/update")
    User updateUser(@RequestBody User user){
        System.out.println(user);
        user.setAge(30);

        return user;

    }


    @DeleteMapping("/delete/{id}")
    User deleteUser(@PathVariable("id") Integer id){
        System.out.println(id);
        return new User(id, "luffy", 19);
    }


}
